package com.wc.alorithm_luogu.P6044_Prawnicy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/7 21:40
 * @description https://www.luogu.com.cn/problem/P6044
 * // 理解错题意思了，我理解成有多少个线段人数>=k个人
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 1000010;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int[] c = new int[N << 1];
    static int n, k;
    static int len = 0;
    static int[] s = new int[N << 1];

    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 1, j = 1; i <= n; i++, j++) {
            a[i] = sc.nextInt();
            c[j] = a[i];
            b[i] = sc.nextInt();
            c[++j] = b[i];
        }
        // 离散化
        Arrays.sort(c, 1, 2 * n + 1);
        int n2 = n * 2;
        for (int i = 1; i <= n2; i++) {
            if (c[i] != c[i - 1]) c[++len] = c[i];
        }
        // 前缀和
        for (int i = 1; i <= n; i++) {
            int l = find(a[i]);
            int r = find(b[i]);
            s[l] += 1;
            s[r + 1] -= 1;
        }
        for (int i = 1; i <= len; i++) s[i] += s[i - 1];
        // 统计 >= k的连续时间记录最大的时间
        int cnt = 0;
        int maxTime = 0;
        int resL = 0;
        for (int i = 1; i <= len; i++) {
            if (s[i] >= k) {
                cnt++;
            } else {
                if (cnt != 0) {
                    int r = i - 1;
                    int l = i - cnt;
                    if (c[r] - c[l] > maxTime) {
                        resL = l;
                        maxTime = c[r] - c[l];
                    }
                }
                cnt = 0;
            }
        }
        if (cnt != 0) {
            int r = len - 1;
            int l = len - cnt;
            if (c[r] - c[l] > maxTime) {
                resL = l;
                maxTime = c[r] - c[l];
            }
        }
        out.println(maxTime);
        int num = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] <= resL && b[i] >= resL) {
                out.print(i + " ");
                if (++num == k) {
                    break;
                }
            }
        }
        out.flush();
    }

    static int find(int x) {
        int l = 1, r = len;
        while (l < r) {
            int mid = l + r >> 1;
            if (c[mid] >= x) r = mid;
            else l = mid + 1;
        }
        return r;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
